package com.woniuxy.store.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.store.core.model.MdSt;
import com.woniuxy.store.core.service.MdStService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/mdSt")
@Api(tags = "三级表")
public class MdStController {
    @Autowired
    MdStService mdStService;

    //查新所有三级连接表
    @GetMapping("/selectAll")
    public CommonResult selectAll(){
        List<MdSt> stList=this.mdStService.list();
        return CommonResult.success(stList);
    }

    //查询一个三级连接表信息
    @ApiOperation("更具服务id获取价格")
    @GetMapping("/selectOne/{stId}")
    public CommonResult selectOne(@PathVariable("stId") int stId) {
        MdSt  mdSt=this.mdStService.selectById(stId);
        System.out.println(mdSt+"!!!!!!!!!!!");
        return CommonResult.success(mdSt);
    }

    //修改一个三级连接表信息
    @PostMapping("updateOne")
    public CommonResult updateOne(@RequestBody MdSt mdSt){
        boolean b=  this.mdStService.updateById(mdSt);
        if(b){
            return CommonResult.success("更新成功");}
        else {
            return CommonResult.fail();
        }
    }

    //增加一个三级连接表信息
    @PostMapping("/insertOne")
    public CommonResult insertOne(@RequestBody MdSt mdSt){
        this.mdStService.insertOne(mdSt);
        return CommonResult.success("插入成功");
    }
    //删除一个三级连接表信息
    @GetMapping("delectOne/{stId}")
    public CommonResult delectOnestore(@PathVariable("stId") int stId) {
        this.mdStService.delectOne(stId);
        return CommonResult.success("注销成功");
    }

}

